#include <iostream>
using namespace std;

int Month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
//是否是闰年
bool isLeap(int year)
{
    return (year % 400 == 0) || (year % 100 != 0 && year % 4 == 0);
}
int main()
{
    int year, month, day, sum = 0;
    cin >> year >> month >> day;
    for (int i = 1; i < month; i++)
    {
        if (i == 2)
        {
            sum += isLeap(year) ? 29 : 28;
        }
        else
        {
            sum += Month[i - 1];
        }
    }
    sum += day;
    printf("%d\n", sum);
}